package com.zb_study.Homework01;

public class homework01 {
    public static void main(String[] args) {
        String str = "abcdef";
        String res = reverse(str, 1, 4);
        System.out.println(res);



//        while (left <= right) {
//            temp = chars[left];
//            chars[left] = chars[right];
//            chars[right] = temp;
//            left++;
//            right--;
//        }

//        for (int i = 0; i < chars.length; i++) {
//            System.out.print(chars[i]);
//        }


    }

    public static String reverse(String str, int start, int end) {

        char[] chars = str.toCharArray();
        char temp = ' ';
        while (start <= end) {
            temp = chars[start];
            chars[start] = chars[end];
            chars[end] = temp;
            start++;
            end--;
        }
       return new String(chars);
    }
}

